(function() {
    var MidWare = function() {
        this.cache = [];
        this.options = {};
    };

    MidWare.prototype = {
        use: function(fn) {
            this.cache.push(fn);
            return this;
        },
        next: function(argument) {
            if(this.cache && this.cache.length > 0) {
                var ware = this.cache.shift();
                ware.call(this, this.options || {}, this.next.bind(this));
            }
        },
        handleRequest: function(options) {
            this.options = options;
            this.next();
        }
    };
    window.midWare = new MidWare();
})();